<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<img src="img/1.jpg" id="pic"/><br />
		<input type="button" value="上一张" onclick="pre()"/>
		<input type="button" value="下一张" onclick="next()"/>
		<script>
			var i=1;
			var next=function(){
				i++;
				if(i>5){
					i=5;
					alert("已经是最后一张了");					
				}else{
					pic.src="img/"+i+".jpg";
				}
			};
			var pre=function(){
				if(i<=1){
					alert("已经是第一张了")
				}else{
					i--;
					pic.src="img/"+i+".jpg";
				}
				
			};
			
		</script>
	</body>
</html>
